package rentaldb;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Pop
 */
@Entity
@Table(name = "property")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Property.findAll", query = "SELECT p FROM Property p"),
    @NamedQuery(name = "Property.findByPropertyId", query = "SELECT p FROM Property p WHERE p.propertyId = :propertyId"),
    @NamedQuery(name = "Property.findByAddress", query = "SELECT p FROM Property p WHERE p.address = :address"),
    @NamedQuery(name = "Property.findByCity", query = "SELECT p FROM Property p WHERE p.city = :city"),
    @NamedQuery(name = "Property.findByState", query = "SELECT p FROM Property p WHERE p.state = :state"),
    @NamedQuery(name = "Property.findByZip", query = "SELECT p FROM Property p WHERE p.zip = :zip"),
    @NamedQuery(name = "Property.findByBeds", query = "SELECT p FROM Property p WHERE p.beds = :beds"),
    @NamedQuery(name = "Property.findByBaths", query = "SELECT p FROM Property p WHERE p.baths = :baths"),
    @NamedQuery(name = "Property.findByCooling", query = "SELECT p FROM Property p WHERE p.cooling = :cooling"),
    @NamedQuery(name = "Property.findByHeating", query = "SELECT p FROM Property p WHERE p.heating = :heating")})
public class Property implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "property_id")
    private Integer propertyId;
    @Column(name = "address")
    private String address;
    @Column(name = "city")
    private String city;
    @Column(name = "State")
    private String state;
    @Column(name = "zip")
    private Integer zip;
    @Column(name = "beds")
    private Integer beds;
    @Column(name = "baths")
    private Integer baths;
    @Column(name = "cooling")
    private String cooling;
    @Column(name = "heating")
    private String heating;
    @OneToMany(mappedBy = "propertyid")
    private Collection<Expense> expenseCollection;
    @OneToMany(mappedBy = "propertyid")
    private Collection<Lease> leaseCollection;
    @OneToMany(mappedBy = "propertyid")
    private Collection<Service> serviceCollection;

    public Property() {
    }

    public Property(Integer propertyId) {
        this.propertyId = propertyId;
    }

    public Integer getPropertyId() {
        return propertyId;
    }

    public void setPropertyId(Integer propertyId) {
        this.propertyId = propertyId;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public Integer getZip() {
        return zip;
    }

    public void setZip(Integer zip) {
        this.zip = zip;
    }

    public Integer getBeds() {
        return beds;
    }

    public void setBeds(Integer beds) {
        this.beds = beds;
    }

    public Integer getBaths() {
        return baths;
    }

    public void setBaths(Integer baths) {
        this.baths = baths;
    }

    public String getCooling() {
        return cooling;
    }

    public void setCooling(String cooling) {
        this.cooling = cooling;
    }

    public String getHeating() {
        return heating;
    }

    public void setHeating(String heating) {
        this.heating = heating;
    }

    @XmlTransient
    public Collection<Expense> getExpenseCollection() {
        return expenseCollection;
    }

    public void setExpenseCollection(Collection<Expense> expenseCollection) {
        this.expenseCollection = expenseCollection;
    }

    @XmlTransient
    public Collection<Lease> getLeaseCollection() {
        return leaseCollection;
    }

    public void setLeaseCollection(Collection<Lease> leaseCollection) {
        this.leaseCollection = leaseCollection;
    }

    @XmlTransient
    public Collection<Service> getServiceCollection() {
        return serviceCollection;
    }

    public void setServiceCollection(Collection<Service> serviceCollection) {
        this.serviceCollection = serviceCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (propertyId != null ? propertyId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Property)) {
            return false;
        }
        Property other = (Property) object;
        if ((this.propertyId == null && other.propertyId != null) || (this.propertyId != null && !this.propertyId.equals(other.propertyId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "propertyId="+propertyId+", address="+address;
    }
    
}
